package package06章_面向对象编程_基础._04oop.exer5_objArr1;

/**
 * @ClassName: package06章_面向对象编程_基础.oop04.exer5_objArr1.StudentTest
 * @Author 86132
 * @Package package06章_面向对象编程_基础.oop04.exer5_objArr
 * @Date 2024/2/10 17:32
 * @description:
 */
public class e_6_07StudentTest {
    public static void main(String[] args) {
        //创建Student[]
        Student[] students = new Student[20]; //String[] strs = new String[20];

        //使用循环，给数组的元素赋值
        for (int i = 0; i < students.length; i++) {
            students[i] = new Student();
            //给每一个学生对象的number、state、score属性赋值
            students[i].number = i + 1;
            students[i].state = (int) (Math.random() * 6 + 1);
            students[i].score = (int) (Math.random() * 101);
        }

        //需求1：打印出3年级(state值为3）的学生信息
        StudentUtil util = new StudentUtil();
        util.printStudentsWithState(students, 3);

        //需求2：使用冒泡排序按学生成绩排序，并遍历所有学生信息
        //排序前遍历
        util.printStudents(students);

        System.out.println("********************");
        util.sortStudents(students);

        //排序后遍历
        util.printStudents(students);


    }
}
